package com.lili.core.bridge.configurer;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.core.io.Resource;
/**
 *
 * @ClassName: CustomPropertyPlaceholderConfigurer
 * @Description: 过滤不存在的Resource
*
 */
public class CustomPropertyPlaceholderConfigurer extends
		PropertyPlaceholderConfigurer {

	@Override
	public void setLocations(Resource[] locations) {
		List<Resource> existResourceList = new ArrayList<Resource>();
		for (int i = 0; i < locations.length; i++) {
			Resource resource = locations[i];
			if(resource.exists())
				existResourceList.add(resource);
		}
		Resource[] existResource = new Resource[existResourceList.size()];
		super.setLocations(existResourceList.toArray(existResource));
	}
}
